package com.ruoyi.project.custom.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
import com.ruoyi.project.custom.domain.CustomFollow;
import com.ruoyi.project.custom.domain.vo.CustomFollowVo;
import com.ruoyi.project.custom.mapper.CustomFollowMapper;
import com.ruoyi.project.custom.service.ICustomFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomFollowServiceImpl implements ICustomFollowService {
    @Autowired
    private CustomFollowMapper followMapper;

    @Override
    public List<CustomFollow> selectCustomFollowList(String customId) {
        return followMapper.selectCustomFollowList(customId);
    }

    @Override
    @DataScope(deptAlias = "t4", userAlias = "t4")
    public List<CustomFollowVo> selectFollowList(CustomFollowVo followVo) {
        return followMapper.selectFollowList(followVo);
    }

    @Override
    public int insertCustomFollow(CustomFollow follow) {
        follow.setCreateBy(SecurityUtils.getLoginUser().getUser().getUserId().toString());
        follow.setUpdateBy(SecurityUtils.getLoginUser().getUser().getUserId().toString());

        return followMapper.insertCustomFollow(follow);
    }

    @Override
    public int updateCustomFollow(CustomFollow follow) {
        follow.setUpdateBy(SecurityUtils.getLoginUser().getUser().getUserId().toString());

        return followMapper.updateCustomFollow(follow);
    }

    @Override
    public int deleteCustomFollow(int id) {
        return followMapper.deleteCustomFollow(id);
    }
}
